﻿#ifndef CCamerSdkOper_H
#define CCamerSdkOper_H
/********************************************************************************
** @ Date:2025/04/29
** @ Author: HanJiaXin
** @ Description:摄像头操作类
** @ Version:1.0.0
** @ ClassName:CCamerSdkOper
** @ Fun:
********************************************************************************/

#include <QObject>
#include <QWidget>
#include "CDevDataCam.h"
#include "CVlcRtspOper.h"
#include "CVlcOper.h"

class CCamerSdkOper  : public QObject
{
	Q_OBJECT

public:
	CCamerSdkOper(CDevDataCam* pDevDataCam);
	~CCamerSdkOper();

	void setCorrectData(double dLeftRectifyValue, double dRightRectifyValue, int nRectifySetValue, int nRectifySetValueTwo, QPointF BeltEdgePf1, QPointF BeltEdgePf2, QPointF BeltEdgePf3, QPointF BeltEdgePf4,
		int nIsHaveBeltState, bool bBeltState);

	bool initAndLogin(QString &sReInfo);                                      //初始化和连接
	bool initCamer(QString &sReInfo);                                         //初始化相机
	bool loginCamer(QString &sReInfo);                                        //用户注册设备
	bool login(QString &sReInfo);											  //外部登录命令
	bool realPlay(int nDevId, WId hHand, QWidget *pWidget, QString &sReInfo); //启动预览 有句柄 
	bool stopRealPlay(WId hHand, QString &sReInfo);                           //停止预览 有句柄 
	bool capture(int nDevId, QString &sPath, QString &sReInfo);               //拍照
	bool getImage(QString &sPath, QString &sReInfo);						  //获取视频帧

private:
	void getDevCfg();                                      //获取设备的通道资源
	void getDecoderCfg();                                  //获取云台解码器信息
	bool captureIr(QString &sPath, QString &sReInfo);                        //红外拍照
	bool captureImg(QString &sPath, QString &sReInfo);                       //图像拍照
	bool captureImgEx(QString &sPath, QString &sReInfo);                     //获取抓拍图并处理划线
	QString getErrMsg();//获取错误描述
	void drawRollerRealign(QImage& image);
	QPen getPenForRectifyValue(double rectifyValue, double setValueTwo, double setValue, int m_nHaveBeltState);

public:
	CDevDataCam *m_pDevDataCam;
	//跑偏画线和左下角文字相关
	QPointF m_BeltEdgePf1;//皮带边缘点1 左上
	QPointF m_BeltEdgePf2;//皮带边缘点2 右上
	QPointF m_BeltEdgePf3;//皮带边缘点3 右下
	QPointF m_BeltEdgePf4;//皮带边缘点4 左下
	double m_dLeftRectifyValue;//左偏值
	double m_dRightRectifyValue;//右偏值
	int m_nRectifySetValue;//一级跑偏判定值
	int m_nRectifySetValueTwo;//二级跑偏判定值
	int m_nIsHaveBeltState;//是否有皮带运行状态
	int m_bBeltState;//皮带运行状态

private:
	QMap<WId, CVlcOper*>m_cMapVlc;   //Rtsp视频对象
	QMap<WId, bool>m_cMapVlcState;   //Rtsp视频对象状态
};
#endif // ifndef CCamerSdkOper_H